using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml.Serialization;
using ICP_MS.Plugin.Tune.Properties;
using ZedGraph;

namespace ICP_MS.Plugin.Tune;

public class FormInstrumentTuneDebug : Form
{
	public class TuneList
	{
		public List<TuneIsotopeAdjustor> tuneIsotopeList = new List<TuneIsotopeAdjustor>();

		public List<TuneRatio> tuneRatioList = new List<TuneRatio>();
	}

	private class TuneStable
	{
		private const int stableCounts = 5;

		private Queue<double> tuneCounts = new Queue<double>();

		public double Stable
		{
			get
			{
				double sd = CalculateDeviation(tuneCounts.ToArray());
				double average = CalculateAverage(tuneCounts.ToArray());
				double rsd = double.NaN;
				if (sd != double.NaN && average != 0.0)
				{
					rsd = sd / average * 100.0;
				}
				return rsd;
			}
		}

		public void Add(double counts)
		{
			if (tuneCounts.Count == 5)
			{
				tuneCounts.Dequeue();
			}
			tuneCounts.Enqueue(counts);
		}

		private double CalculateAverage(double[] counts)
		{
			return counts.Average();
		}

		private double CalculateDeviation(double[] counts)
		{
			double sum = 0.0;
			double sum2 = 0.0;
			int counter = 0;
			for (int i = 0; i < counts.Length; i++)
			{
				int val = (int)counts[i];
				sum += (double)val * 1.0;
				sum2 += (double)val * 1.0 * (double)val;
				counter++;
			}
			if (counter < 2)
			{
				return double.NaN;
			}
			return Math.Sqrt(((double)counter * sum2 - sum * sum) / (double)counter / (double)(counter - 1));
		}
	}

	private DateTime time = DateTime.Now;

	public static bool IsRun;

	private bool bConfigChanged = false;

	private int AnalogMode = 0;

	public AutoResetEvent scanEvent = new AutoResetEvent(initialState: false);

	public TuneList tuneList = new TuneList();

	private const int TuneCounts = 16;

	private const int RatioCounts = 4;

	private Thread threadRefresh = null;

	private const int paneNums = 3;

	private GraphPane[] paneArray = new GraphPane[3];

	private GraphPane[] paneArray1 = new GraphPane[3];

	private volatile bool tuneStop = true;

	private volatile int lineShow = 0;

	private KnownColor[] knowColors = new KnownColor[20]
	{
		KnownColor.Red,
		KnownColor.Green,
		KnownColor.Blue,
		KnownColor.Gold,
		KnownColor.Goldenrod,
		KnownColor.Indigo,
		KnownColor.GreenYellow,
		KnownColor.Lime,
		KnownColor.OrangeRed,
		KnownColor.Teal,
		KnownColor.Aquamarine,
		KnownColor.Firebrick,
		KnownColor.Violet,
		KnownColor.LightCyan,
		KnownColor.Cornsilk,
		KnownColor.SkyBlue,
		KnownColor.Yellow,
		KnownColor.PaleGreen,
		KnownColor.Beige,
		KnownColor.CornflowerBlue
	};

	private TuneStable[] tuneStables = null;

	private TuneStable[] ratioStables = null;

	private ComboBox cbDgvEdit = null;

	private IContainer components = null;

	private ToolStrip toolStrip1;

	private TableLayoutPanel tableLayoutPanel1;

	private Panel panel1;

	private ToolStripButton tsbtnStop;

	private ToolStripSeparator toolStripSeparator5;

	private ToolStripSeparator toolStripSeparator4;

	private ToolStripComboBox tscbPaneMode;

	private DataGridViewTextBoxColumn dataGridViewTextBoxColumn1;

	private DataGridViewTextBoxColumn dataGridViewTextBoxColumn2;

	private DataGridViewTextBoxColumn dataGridViewTextBoxColumn3;

	private DataGridViewTextBoxColumn dataGridViewTextBoxColumn4;

	private DataGridViewTextBoxColumn dataGridViewTextBoxColumn5;

	private DataGridViewTextBoxColumn dataGridViewTextBoxColumn6;

	private DataGridViewTextBoxColumn dataGridViewTextBoxColumn7;

	private DataGridViewTextBoxColumn dataGridViewTextBoxColumn8;

	private DataGridViewTextBoxColumn dataGridViewTextBoxColumn9;

	private DataGridViewTextBoxColumn dataGridViewTextBoxColumn10;

	private DataGridViewTextBoxColumn dataGridViewTextBoxColumn11;

	private DataGridViewTextBoxColumn dataGridViewTextBoxColumn12;

	private DataGridViewTextBoxColumn dataGridViewTextBoxColumn13;

	private DataGridViewTextBoxColumn dataGridViewTextBoxColumn14;

	private ZedGraphControl graphControlTuneGraph;

	private ToolStripButton tsbtnSetupRun;

	private TableLayoutPanel tableLayoutPanel4;

	private DataGridView dgvTuneIsotopes;

	private DataGridViewTextBoxColumn dataGridViewTextBoxColumn15;

	private DataGridViewTextBoxColumn dataGridViewTextBoxColumn16;

	private DataGridViewTextBoxColumn dataGridViewTextBoxColumn17;

	private DataGridViewTextBoxColumn dataGridViewTextBoxColumn18;

	private DataGridViewTextBoxColumn dataGridViewTextBoxColumn19;

	private DataGridViewTextBoxColumn dataGridViewTextBoxColumn20;

	private DataGridViewTextBoxColumn dataGridViewTextBoxColumn21;

	private DataGridViewTextBoxColumn dataGridViewTextBoxColumn22;

	private DataGridViewTextBoxColumn dataGridViewTextBoxColumn23;

	private DataGridViewTextBoxColumn dataGridViewTextBoxColumn24;

	private DataGridViewTextBoxColumn dataGridViewTextBoxColumn25;

	private DataGridViewTextBoxColumn dataGridViewTextBoxColumn26;

	private DataGridViewTextBoxColumn dataGridViewTextBoxColumn27;

	private ToolStripComboBox tscbAnalog;

	private DataGridView dgvTuneRatio;

	private DataGridViewTextBoxColumn colRatioColor;

	private DataGridViewComboBoxColumn colRatioNumerator;

	private DataGridViewComboBoxColumn colRatioDenominator;

	private DataGridViewCheckBoxColumn colRatioVisible;

	private DataGridViewTextBoxColumn colRatio;

	private DataGridViewTextBoxColumn colRatioStable;

	private DataGridViewTextBoxColumn colColorTune;

	private DataGridViewTextBoxColumn colSymbolTune;

	private DataGridViewTextBoxColumn colAMUTune;

	private DataGridViewCheckBoxColumn colEnableTune;

	private DataGridViewCheckBoxColumn colVisibleTune;

	private DataGridViewTextBoxColumn colSpacingTune;

	private DataGridViewTextBoxColumn colDwellTune;

	private DataGridViewTextBoxColumn colChannelsTune;

	private DataGridViewTextBoxColumn colResolution;

	private DataGridViewTextBoxColumn colCountsTune;

	private DataGridViewTextBoxColumn colStableTune;

	private event EventHandler ConfigsChanged = null;

	public FormInstrumentTuneDebug()
	{
		InitializeComponent();
	}

	private void FormInstrument_Load(object sender, EventArgs e)
	{
		base.WindowState = FormWindowState.Maximized;
		UserManager.UserChanged += UserManager_UserChanged;
		Detector.ExperimentStateChanged += Detector_ExperimentStateChanged;
		ApplyResources();
		TuneLoad();
	}

	private void dgvTuneRatio_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
	{
		if (e.ColumnIndex < 0 || e.RowIndex < 0)
		{
			return;
		}
		string dataPropertyName = dgvTuneRatio.Columns[e.ColumnIndex].DataPropertyName;
		string text = dataPropertyName;
		if (text == "Color")
		{
			ColorDialog colorDialog = new ColorDialog();
			colorDialog.Color = Color.FromArgb(tuneList.tuneRatioList[e.RowIndex].Color);
			if (colorDialog.ShowDialog() == DialogResult.OK)
			{
				tuneList.tuneRatioList[e.RowIndex].Color = colorDialog.Color.ToArgb();
			}
		}
	}

	private void dgvTuneRatio_CellValueChanged(object sender, DataGridViewCellEventArgs e)
	{
		if (e.RowIndex < 0 || e.ColumnIndex < 0)
		{
			return;
		}
		string dataPropertyName = dgvTuneRatio.Columns[e.ColumnIndex].DataPropertyName;
		string text = dataPropertyName;
		if (text == "NumeratorSym" || text == "DenominatorSym")
		{
			if (tuneList.tuneRatioList[e.RowIndex].NumeratorSym != null && tuneList.tuneRatioList[e.RowIndex].DenominatorSym != null)
			{
				dgvTuneRatio.Rows[e.RowIndex].Cells[colRatioVisible.Index].ReadOnly = false;
				tuneList.tuneRatioList[e.RowIndex].Visible = true;
			}
			else
			{
				dgvTuneRatio.Rows[e.RowIndex].Cells[colRatioVisible.Index].ReadOnly = true;
				tuneList.tuneRatioList[e.RowIndex].Visible = false;
			}
			dgvTuneRatio.InvalidateRow(e.RowIndex);
		}
	}

	private void dgvTuneRatio_KeyDown(object sender, KeyEventArgs e)
	{
		if (e.KeyCode == Keys.Delete && dgvTuneRatio.SelectedCells.Count > 0)
		{
			int rowIndex = dgvTuneRatio.SelectedCells[0].RowIndex;
			int colIndex = dgvTuneRatio.SelectedCells[0].ColumnIndex;
			if (colIndex == colRatioNumerator.Index || colIndex == colRatioDenominator.Index)
			{
				tuneList.tuneRatioList[rowIndex].NumeratorSym = null;
				tuneList.tuneRatioList[rowIndex].DenominatorSym = null;
				tuneList.tuneRatioList[rowIndex].Ratio = -1.0;
				tuneList.tuneRatioList[rowIndex].Stability = -1.0;
				tuneList.tuneRatioList[rowIndex].Visible = false;
				dgvTuneRatio[colRatioVisible.Index, rowIndex].ReadOnly = true;
				dgvTuneRatio.InvalidateRow(rowIndex);
			}
		}
	}

	private void dgvTuneRatio_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
	{
		switch (dgvTuneRatio.Columns[e.ColumnIndex].DataPropertyName)
		{
		case "Color":
			dgvTuneRatio[e.ColumnIndex, e.RowIndex].Style.BackColor = Color.FromArgb(tuneList.tuneRatioList[e.RowIndex].Color);
			e.Value = null;
			break;
		case "NumeratorSym":
			break;
		case "DenominatorSym":
			break;
		case "Ratio":
		case "Stability":
		{
			double value = Convert.ToDouble(e.Value);
			if (value < 0.0)
			{
				e.Value = null;
			}
			else
			{
				e.Value = value.ToString("F3");
			}
			break;
		}
		}
	}

	private void dgvTuneRatio_CurrentCellDirtyStateChanged(object sender, EventArgs e)
	{
		if (dgvTuneRatio.IsCurrentCellDirty)
		{
			dgvTuneRatio.CommitEdit(DataGridViewDataErrorContexts.Commit);
		}
	}

	private void RemoveInvalidRatios()
	{
		IEnumerable<string> symbols = from isotope in tuneList.tuneIsotopeList
			where isotope.symbol != null
			select isotope.symbol;
		foreach (TuneRatio ratio in tuneList.tuneRatioList)
		{
			if (!symbols.Contains(ratio.NumeratorSym) || !symbols.Contains(ratio.DenominatorSym))
			{
				ratio.NumeratorSym = null;
				ratio.DenominatorSym = null;
				ratio.Ratio = -1.0;
				ratio.Stability = -1.0;
				ratio.Visible = false;
			}
		}
		dgvTuneRatio.Refresh();
	}

	private void SetRatioEnabled()
	{
		IEnumerable<string> symbols = from isotope in tuneList.tuneIsotopeList
			where isotope.symbol != null && !isotope.enable
			select isotope.symbol;
		for (int i = 0; i < 4 && i < tuneList.tuneRatioList.Count; i++)
		{
			TuneRatio ratio = tuneList.tuneRatioList[i];
			if (symbols.Contains(ratio.NumeratorSym) || symbols.Contains(ratio.DenominatorSym))
			{
				ratio.Ratio = -1.0;
				ratio.Stability = -1.0;
				ratio.Visible = false;
				dgvTuneRatio.Rows[i].Cells[colRatioVisible.Index].ReadOnly = true;
				dgvTuneRatio.InvalidateRow(i);
			}
			else
			{
				dgvTuneRatio.Rows[i].Cells[colRatioVisible.Index].ReadOnly = false;
				dgvTuneRatio.InvalidateRow(i);
			}
		}
	}

	private void LoadRatioSymbols()
	{
		IEnumerable<string> names = from isotope in tuneList.tuneIsotopeList
			where isotope.symbol != null
			select isotope.symbol;
		colRatioNumerator.Items.Clear();
		colRatioDenominator.Items.Clear();
		if (names != null && names.Count() > 0)
		{
			DataGridViewComboBoxCell.ObjectCollection items = colRatioNumerator.Items;
			object[] items2 = names.ToArray();
			items.AddRange(items2);
			DataGridViewComboBoxCell.ObjectCollection items3 = colRatioDenominator.Items;
			items2 = names.ToArray();
			items3.AddRange(items2);
		}
	}

	private void Detector_ExperimentStateChanged(object sender, ExperimentStateArgs e)
	{
		if (e.State == 1)
		{
			StopTune();
		}
	}

	private void ApplyResources()
	{
		Text = Lang.Txt("FormInstrumentTune.Title.Text");
		colAMUTune.HeaderText = Lang.Txt("FormInstrumentTune.Columns.Mass.Text");
		colChannelsTune.HeaderText = Lang.Txt("FormInstrumentTune.Columns.Channel.Text");
		colColorTune.HeaderText = Lang.Txt("FormInstrumentTune.Columns.Color.Text");
		colCountsTune.HeaderText = Lang.Txt("FormInstrumentTune.Columns.CPS.Text");
		colEnableTune.HeaderText = Lang.Txt("FormInstrumentTune.Columns.Open.Text");
		colSpacingTune.HeaderText = Lang.Txt("FormInstrumentTune.Columns.gap.Text");
		colStableTune.HeaderText = Lang.Txt("FormInstrumentTune.Columns.Stable.Text");
		colSymbolTune.HeaderText = Lang.Txt("FormInstrumentTune.Columns.Symbol.Text");
		colVisibleTune.HeaderText = Lang.Txt("FormInstrumentTune.Columns.Visible.Text");
		tscbPaneMode.Items[0] = Lang.Txt("FormInstrumentTune.Intensity.Time.Text");
		tscbPaneMode.Items[1] = Lang.Txt("FormInstrumentTune.Intensity.Mass.Text");
		tsbtnSetupRun.Text = Lang.Txt("ADDTune.TuneDebug.SetupAndScan");
		tsbtnStop.Text = Lang.Txt("ADDTune.TuneDebug.StopTune");
		tscbAnalog.Items[0] = Lang.Txt("ADDTune.TuneDebug.OriginalAnalogMode");
		tscbAnalog.Items[1] = Lang.Txt("ADDTune.TuneDebug.CorrectionAnalogMode");
		colColorTune.HeaderText = Lang.Txt("ADDTune.TuneDebug.Color");
		colSymbolTune.HeaderText = Lang.Txt("ADDTune.TuneDebug.Element");
		colAMUTune.HeaderText = Lang.Txt("ADDTune.TuneDebug.Mass");
		colEnableTune.HeaderText = Lang.Txt("ADDTune.TuneDebug.Open");
		colVisibleTune.HeaderText = Lang.Txt("ADDTune.TuneDebug.Display");
		colSpacingTune.HeaderText = Lang.Txt("ADDTune.TuneDebug.Spacing");
		colChannelsTune.HeaderText = Lang.Txt("ADDTune.TuneDebug.Channel");
		colResolution.HeaderText = Lang.Txt("ADDTune.TuneDebug.Resolution");
		colCountsTune.HeaderText = Lang.Txt("ADDTune.TuneDebug.Count");
		colStableTune.HeaderText = Lang.Txt("ADDTune.TuneDebug.Stability");
		colRatioColor.HeaderText = Lang.Txt("ADDTune.TuneDebug.Color");
		colRatioNumerator.HeaderText = Lang.Txt("ADDTune.TuneDebug.Molecular");
		colRatioDenominator.HeaderText = Lang.Txt("ADDTune.TuneDebug.Denominator");
		colRatioVisible.HeaderText = Lang.Txt("ADDTune.TuneDebug.Display");
		colRatio.HeaderText = Lang.Txt("ADDTune.TuneDebug.Ratio");
		colRatioStable.HeaderText = Lang.Txt("ADDTune.TuneDebug.Stability");
	}

	private void UserManager_UserChanged(object sender, EventArgs e)
	{
	}

	private void FormInstrumentSetup_FormClosing(object sender, FormClosingEventArgs e)
	{
		SaveTuneIsotopes();
		TuneClose();
		UserManager.UserChanged -= UserManager_UserChanged;
		Detector.ExperimentStateChanged -= Detector_ExperimentStateChanged;
	}

	private void PermissionManagement()
	{
	}

	public void StopRun()
	{
		StopTune();
	}

	private void TuneLoad()
	{
		loadTuneIsotopes();
		setupTuneGraphCurve();
		tscbPaneMode.SelectedIndex = 0;
		tscbAnalog.SelectedIndex = 0;
		tuneStables = new TuneStable[16];
		for (int j = 0; j < 16; j++)
		{
			tuneStables[j] = new TuneStable();
		}
		ratioStables = new TuneStable[4];
		for (int i = 0; i < 4; i++)
		{
			ratioStables[i] = new TuneStable();
		}
	}

	private void Detector_errorReceive(object sender, EventArgs e)
	{
		StopRun();
		MessageBox.Show(Lang.Txt("FormExperLog.Text2"), Lang.Txt("AddFormIgnite.Warn"), MessageBoxButtons.OK);
	}

	private void TuneClose()
	{
		Detector.finishReceive -= MassDetector_msTuneEventhandler;
		Detector.errorevent -= Detector_errorReceive;
		DataBase.Instance.SaveTuneRatios(tuneList.tuneRatioList);
		StopRefreshTune();
	}

	private void InitIsotope(ref TuneIsotopeAdjustor isotope)
	{
		isotope.atom = null;
		isotope.symbol = null;
		isotope.mass = 9999.0;
		isotope.resolution = -1;
		isotope.spacing = -1;
		isotope.stable = -1.0;
		isotope.channels = -1;
		isotope.dwell = -1;
		isotope.counts = -1;
		isotope.enable = false;
		isotope.visible = false;
	}

	private void InitTuneIsotopes()
	{
		tuneList.tuneIsotopeList = new List<TuneIsotopeAdjustor>();
		for (int i = 0; i < 16; i++)
		{
			TuneIsotopeAdjustor isotope = new TuneIsotopeAdjustor();
			isotope.color = Color.FromKnownColor(knowColors[i]).ToArgb();
			InitIsotope(ref isotope);
			tuneList.tuneIsotopeList.Add(isotope);
		}
	}

	private void InitTuneRatios()
	{
		tuneList.tuneRatioList = new List<TuneRatio>();
		for (int i = 0; i < 4; i++)
		{
			TuneRatio ratio = new TuneRatio();
			ratio.Color = Color.FromKnownColor(knowColors[i + 16]).ToArgb();
			ratio.Ratio = -1.0;
			ratio.Stability = -1.0;
			ratio.Visible = false;
			tuneList.tuneRatioList.Add(ratio);
		}
	}

	private void loadTuneIsotopes()
	{
		string filename = Application.StartupPath + "\\iMassConfig\\调谐质量数.xml";
		if (File.Exists(filename))
		{
			using FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read);
			try
			{
				XmlSerializer serializer = new XmlSerializer(typeof(TuneList));
				TuneList tiaList = serializer.Deserialize(fs) as TuneList;
				if (tiaList != null)
				{
					tuneList.tuneIsotopeList.Clear();
					tuneList.tuneIsotopeList.AddRange(tiaList.tuneIsotopeList.ToArray());
				}
				List<TuneRatio> ratioLists = tiaList.tuneRatioList;
				if (ratioLists == null || ratioLists.Count < 4)
				{
					InitTuneRatios();
				}
				else
				{
					tuneList.tuneRatioList = new List<TuneRatio>(ratioLists);
				}
				LoadRatioSymbols();
			}
			catch
			{
				MessageBox.Show(Lang.Txt("FormScanNCS.MessageBox.FileNotOK.Text"));
			}
		}
		if (tuneList.tuneIsotopeList == null || tuneList.tuneIsotopeList.Count < 16)
		{
			InitTuneIsotopes();
		}
		if (tuneList.tuneRatioList == null || tuneList.tuneRatioList.Count < 4)
		{
			InitTuneRatios();
		}
		LoadRatioSymbols();
		dgvTuneIsotopes.DataSource = tuneList.tuneIsotopeList;
		dgvTuneIsotopes.Refresh();
		dgvTuneIsotopes.Columns["id"].Visible = false;
		dgvTuneIsotopes.Columns["atom"].Visible = false;
		dgvTuneIsotopes.Columns["countsAnalog"].Visible = false;
		dgvTuneRatio.AutoGenerateColumns = false;
		dgvTuneRatio.DataSource = tuneList.tuneRatioList;
	}

	private void SaveTuneIsotopes()
	{
		using FileStream fs = new FileStream(Application.StartupPath + "\\iMassConfig\\调谐质量数.xml", FileMode.Create, FileAccess.Write);
		try
		{
			XmlSerializer serializer = new XmlSerializer(typeof(TuneList));
			serializer.Serialize(fs, tuneList);
		}
		catch
		{
			MessageBox.Show(Lang.Txt("FormScanNCS.MessageBox.FileNotOK.Text"));
		}
	}

	private void dataGridViewTuneIsotopes_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
	{
		if (e.ColumnIndex < 0 || e.RowIndex < 0)
		{
			return;
		}
		string dataPropertyName = dgvTuneIsotopes.Columns[e.ColumnIndex].DataPropertyName;
		string text = dataPropertyName;
		if (!(text == "color"))
		{
			if (!(text == "symbol"))
			{
				return;
			}
			TuneIsotopeAdjustor isotope = tuneList.tuneIsotopeList[e.RowIndex];
			FormMassSelect formMassSelect = new FormMassSelect(DataBase.Instance, isotope.symbol);
			if (formMassSelect.ShowDialog() != DialogResult.OK)
			{
				return;
			}
			isotope.atom = formMassSelect.SelectedIsotope.atomicSymbol;
			isotope.symbol = formMassSelect.SelectedIsotope.symbol;
			isotope.mass = formMassSelect.SelectedIsotope.mass;
			isotope.spacing = 20;
			isotope.channels = 1;
			isotope.dwell = 10;
			isotope.resolution = 1;
			isotope.enable = true;
			isotope.visible = true;
			dgvTuneIsotopes.InvalidateRow(e.RowIndex);
			ShowlineofPane(e.RowIndex, visible: true);
			for (int i = 0; i < tuneList.tuneIsotopeList.Count; i++)
			{
				if (tuneList.tuneIsotopeList[i].symbol == isotope.symbol && i != e.RowIndex)
				{
					TuneIsotopeAdjustor ti = tuneList.tuneIsotopeList[i];
					InitIsotope(ref ti);
					dgvTuneIsotopes.InvalidateRow(i);
				}
			}
			dgvTuneIsotopes.DataSource = tuneList.tuneIsotopeList;
			dgvTuneIsotopes.Refresh();
			dgvTuneIsotopes.Columns["id"].Visible = false;
			dgvTuneIsotopes.Columns["atom"].Visible = false;
			dgvTuneIsotopes.Columns["countsAnalog"].Visible = false;
			LoadRatioSymbols();
			RemoveInvalidRatios();
		}
		else
		{
			ColorDialog colorDialog = new ColorDialog();
			colorDialog.Color = Color.FromArgb(tuneList.tuneIsotopeList[e.RowIndex].color);
			if (colorDialog.ShowDialog() == DialogResult.OK)
			{
				tuneList.tuneIsotopeList[e.RowIndex].color = colorDialog.Color.ToArgb();
				graphControlTuneGraph.MasterPane.PaneList[0].CurveList[e.RowIndex].Color = colorDialog.Color;
				graphControlTuneGraph.MasterPane.PaneList[1].CurveList[e.RowIndex].Color = colorDialog.Color;
			}
		}
	}

	private void dgvTuneIsotopes_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
	{
		switch (dgvTuneIsotopes.Columns[e.ColumnIndex].DataPropertyName)
		{
		case "color":
			dgvTuneIsotopes[e.ColumnIndex, e.RowIndex].Style.BackColor = Color.FromArgb(tuneList.tuneIsotopeList[e.RowIndex].color);
			e.Value = null;
			break;
		case "symbol":
			if (e.Value == null)
			{
				dgvTuneIsotopes.Rows[e.RowIndex].Cells["colEnableTune"].ReadOnly = true;
				dgvTuneIsotopes.Rows[e.RowIndex].Cells["colVisibleTune"].ReadOnly = true;
			}
			else
			{
				dgvTuneIsotopes.Rows[e.RowIndex].Cells["colEnableTune"].ReadOnly = false;
				dgvTuneIsotopes.Rows[e.RowIndex].Cells["colVisibleTune"].ReadOnly = false;
			}
			break;
		case "mass":
			if (Convert.ToDouble(e.Value) == 9999.0)
			{
				e.Value = null;
			}
			else
			{
				e.Value = $"{e.Value:0.000}";
			}
			break;
		case "stable":
			if (Convert.ToDouble(e.Value) < 0.0)
			{
				e.Value = null;
			}
			else
			{
				e.Value = $"{e.Value:0.000}";
			}
			break;
		case "spacing":
		case "dwell":
		case "channels":
		case "counts":
			if (Convert.ToInt32(e.Value) < 0)
			{
				e.Value = null;
			}
			break;
		case "resolution":
			e.Value = (((int)e.Value == 1) ? Lang.Txt("ADDTune.TuneDebug.Normal") : (((int)e.Value == 0) ? Lang.Txt("ADDTune.TuneDebug.High") : Lang.Txt("ADDTune.TuneDebug.Low")));
			break;
		}
	}

	private void dgvTuneIsotopes_CurrentCellDirtyStateChanged(object sender, EventArgs e)
	{
		if (dgvTuneIsotopes.IsCurrentCellDirty)
		{
			dgvTuneIsotopes.CommitEdit(DataGridViewDataErrorContexts.Commit);
		}
	}

	private void dgvTuneIsotopes_KeyDown(object sender, KeyEventArgs e)
	{
		if (e.KeyCode == Keys.Delete && dgvTuneIsotopes.SelectedCells.Count > 0 && dgvTuneIsotopes.SelectedCells[0].OwningColumn.Name.Equals("colSymbolTune"))
		{
			int rowIndex = dgvTuneIsotopes.SelectedCells[0].RowIndex;
			TuneIsotopeAdjustor isotope = tuneList.tuneIsotopeList[rowIndex];
			InitIsotope(ref isotope);
			dgvTuneIsotopes.InvalidateRow(rowIndex);
			dgvTuneIsotopes.DataSource = tuneList.tuneIsotopeList;
			dgvTuneIsotopes.Refresh();
			dgvTuneIsotopes.Columns["id"].Visible = false;
			dgvTuneIsotopes.Columns["atom"].Visible = false;
			dgvTuneIsotopes.Columns["countsAnalog"].Visible = false;
			LoadRatioSymbols();
			RemoveInvalidRatios();
		}
	}

	private void dataGridViewTuneIsotopes_CellValueChanged(object sender, DataGridViewCellEventArgs e)
	{
		string dataPropertyName = dgvTuneIsotopes.Columns[e.ColumnIndex].DataPropertyName;
		string text = dataPropertyName;
		if (!(text == "enable"))
		{
			if (text == "visible" && !tuneStop)
			{
				ShowlineofPane(e.RowIndex, Convert.ToBoolean(dgvTuneIsotopes[e.ColumnIndex, e.RowIndex].Value));
			}
		}
		else
		{
			bConfigChanged = true;
		}
	}

	private void toolStripButtonInstrumentSetupSave_Click(object sender, EventArgs e)
	{
		SaveFileDialog dlg = new SaveFileDialog();
		dlg.Filter = "Xml files(*.xml)|*.xml";
		dlg.InitialDirectory = Application.StartupPath + "\\iMassConfig";
		dlg.FileName = "调谐质量数.xml";
		if (dlg.ShowDialog() == DialogResult.OK)
		{
			using (FileStream fs = new FileStream(dlg.FileName, FileMode.Create, FileAccess.Write))
			{
				XmlSerializer serializer = new XmlSerializer(typeof(List<TuneIsotopeAdjustor>));
				serializer.Serialize(fs, tuneList.tuneIsotopeList);
			}
		}
	}

	private void toolStripButtonInstrumentSetupOpen_Click(object sender, EventArgs e)
	{
		OpenFileDialog dlg = new OpenFileDialog();
		dlg.Filter = "Xml files(*.xml)|*.xml";
		dlg.InitialDirectory = Application.StartupPath + "\\iMassConfig";
		dlg.FileName = "调谐质量数.xml";
		if (dlg.ShowDialog() != DialogResult.OK)
		{
			return;
		}
		using FileStream fs = new FileStream(dlg.FileName, FileMode.Open, FileAccess.Read);
		try
		{
			XmlSerializer serializer = new XmlSerializer(typeof(List<TuneIsotopeAdjustor>));
			if (serializer.Deserialize(fs) is List<TuneIsotopeAdjustor> tiaList)
			{
				tuneList.tuneIsotopeList.Clear();
				tuneList.tuneIsotopeList.AddRange(tiaList.ToArray());
				dgvTuneIsotopes.DataSource = tuneList.tuneIsotopeList;
				dgvTuneIsotopes.Refresh();
			}
		}
		catch
		{
			MessageBox.Show(Lang.Txt("FormScanNCS.MessageBox.FileNotOK.Text"));
		}
	}

	private void LoadConfigration(string name)
	{
		X2Lens lens = DataBase.Instance.GetX2Lens(name);
		if (lens != null)
		{
			LensManager.x2lens = lens.Clone();
			LensManager.Instance.X2_SetAll();
			Thread.Sleep(1000);
		}
		else
		{
			Log.InsertLog("Configration", "Load lens params error.", "", (Severity)3);
		}
		PlasmaPara plasma = DataBase.Instance.GetPlasma(name);
		if (plasma != null)
		{
			PlasmaManager.plasma = plasma.Clone();
		}
		else
		{
			Log.InsertLog("Configration", "Load plasma params error.", "", (Severity)3);
		}
		Platform plat = DataBase.Instance.GetPlatform(name);
		if (plat != null)
		{
			PlatManager.plat = plat.Clone();
		}
		else
		{
			Log.InsertLog("Configration", "Load platform params error.", "", (Severity)3);
		}
		RFS rfs = DataBase.Instance.GetRFS(name);
		if (rfs != null)
		{
			RFManager.rfs = rfs.Clone();
			Detector.Instance.msDetectorRF.SetRfs();
		}
		else
		{
			Log.InsertLog("Configration", "Load rf params error.", "", (Severity)3);
		}
		InstrumentInjector injector = DataBase.Instance.GetInjector(name);
		if (injector != null)
		{
			PlatManager.Instrumentinjector = injector.Clone();
			Plasma.Instance.SetPeristaltic(PlatManager.Instrumentinjector.Perist);
		}
	}

	private void SaveConfigration(string description, bool changeConfig = true)
	{
		if (changeConfig)
		{
			IList<InstrumentConfig> cfgs = DataBase.Instance.GetAllInstrumentConfigs();
			if (cfgs != null)
			{
				foreach (InstrumentConfig cfg in cfgs)
				{
					cfg.Used = false;
				}
			}
			DataBase.Instance.SaveInstrumentConfigs(cfgs);
		}
		string time = DateTime.Now.ToString();
		InstrumentConfig config = new InstrumentConfig();
		config.Description = description;
		config.Time = time;
		config.Used = changeConfig;
		config.User = Environment.UserName;
		if (DataBase.Instance.SaveInstrumentConfig(config))
		{
			X2Lens lens = LensManager.x2lens.Clone();
			lens.name = time;
			Platform plat = PlatManager.plat.Clone();
			plat.name = time;
			PlasmaPara plasma = PlasmaManager.plasma.Clone();
			plasma.Name = time;
			RFS rfs = RFManager.rfs.Clone();
			rfs.name = time;
			InstrumentInjector injector = PlatManager.Instrumentinjector.Clone();
			injector.Name = time;
			if (!DataBase.Instance.SaveX2Lens(lens) || !DataBase.Instance.SavePlatform(plat) || !DataBase.Instance.SavePlasma(plasma) || !DataBase.Instance.SaveRFS(rfs) || !DataBase.Instance.SaveInjector(injector))
			{
				MessageBox.Show(Lang.Txt("Tune.Text35"));
			}
		}
		else
		{
			MessageBox.Show(Lang.Txt("Tune.Text36"));
		}
	}

	public void DisableTune()
	{
		StopTune();
		tsbtnSetupRun.Enabled = false;
		tsbtnStop.Enabled = false;
		dgvTuneIsotopes.Enabled = false;
	}

	public void EnableTune()
	{
		Invoke((EventHandler)delegate
		{
			tsbtnSetupRun.Enabled = true;
			tsbtnStop.Enabled = true;
			dgvTuneIsotopes.Enabled = true;
		});
	}

	private void SetTuneMassAxis()
	{
		List<double> mass = new List<double>();
		List<int> res = new List<int>();
		foreach (TuneIsotopeAdjustor isotope in tuneList.tuneIsotopeList)
		{
			if (isotope.enable)
			{
				for (int i = -isotope.channels / 2; i <= isotope.channels / 2; i++)
				{
					mass.Add(isotope.mass + (double)(i * isotope.spacing) * 0.001);
					res.Add(isotope.resolution);
				}
			}
		}
		Detector.Instance.SetHopDatas(mass.ToArray(), (double[])null, res.ToArray(), true, false);
	}

	public void StartTune()
	{
		if (!tuneStop)
		{
			StopTune();
		}
		Invoke((MethodInvoker)delegate
		{
			SetupPane0();
			SetupPane1();
			Detector.finishReceive += MassDetector_msTuneEventhandler;
			Detector.errorevent += Detector_errorReceive;
			StopRefreshTune();
			tuneStop = false;
			Detector.Instance.ExperimentState = 1;
		});
		while (!tuneStop)
		{
			if (bConfigChanged)
			{
				Invoke((MethodInvoker)delegate
				{
					SetupPane0();
					SetupPane1();
				});
				bConfigChanged = false;
			}
			SetTuneMassAxis();
			if (!scanEvent.WaitOne(10000))
			{
				MessageBox.Show(Lang.Txt("FormExperLog.Text3"), Lang.Txt("AddFormIgnite.Warn"), MessageBoxButtons.OK);
				StopTune();
				break;
			}
			if (tuneStop)
			{
				break;
			}
			CalculateTuneResults();
			DrawCurve();
			Invoke((MethodInvoker)delegate
			{
				try
				{
					using Graphics g = graphControlTuneGraph.CreateGraphics();
					graphControlTuneGraph.MasterPane.SetLayout(g, PaneLayout.SingleRow);
					graphControlTuneGraph.MasterPane.AxisChange(g);
					graphControlTuneGraph.Refresh();
				}
				catch
				{
				}
			});
		}
	}

	private void StopRefreshTune()
	{
		if (threadRefresh != null)
		{
			threadRefresh.Abort();
			threadRefresh = null;
		}
	}

	private void StopTune()
	{
		if (!tuneStop)
		{
			tuneStop = true;
			Detector.finishReceive -= MassDetector_msTuneEventhandler;
			Detector.errorevent -= Detector_errorReceive;
			Detector.Instance.Stop();
			Thread.Sleep(200);
			scanEvent.Set();
			Detector.Instance.ExperimentState = -1;
		}
	}

	private void tsbtnSetRun_Click(object sender, EventArgs e)
	{
		if (Detector.Instance.ExperimentState != -1)
		{
			if (Detector.Instance.ExperimentState == 1)
			{
				MessageBox.Show(Lang.Txt("ADDTune.TipsText1.Text"), Lang.Txt("AddFormIgnite.Warn"));
				return;
			}
			if (MessageBox.Show(Lang.Txt("ADDTune.TipsText2.Text"), Lang.Txt("AddFormIgnite.Warn"), MessageBoxButtons.YesNo) != DialogResult.Yes)
			{
				return;
			}
			Detector.Instance.ExperimentStateChange(Detector.Instance.ExperimentState);
		}
		Task.Factory.StartNew(StartTune);
	}

	private void StartMonitor()
	{
		List<double> hexCoef = new List<double>();
		List<double> DC = new List<double>();
		List<double> RF = new List<double>();
		List<double> Power = new List<double>();
		while (!tuneStop)
		{
			hexCoef.Add(LensManager.x2lens.ReadHex);
			DC.Add(QuadMonitor.quad.ReadDC);
			RF.Add(QuadMonitor.quad.ReadRF);
			Power.Add(PlasmaManager.plasma.ReadForward);
			Thread.Sleep(200);
		}
		StreamWriter sw = null;
		string str = "";
		for (int i = 0; i < hexCoef.Count; i++)
		{
			str = str + hexCoef[i] + "," + DC[i] + "," + RF[i] + "," + Power[i] + "\n";
		}
		sw = new StreamWriter(DateTime.Now.ToString("yyyy-MM-dd_hh-mm-ss") + ".csv", append: false, Encoding.GetEncoding("GB2312"));
		sw.Write(str);
		sw.Close();
	}

	private void toolStripButtonInstrumentSetupStop_Click(object sender, EventArgs e)
	{
		StopTune();
	}

	private void CalculateTuneResults()
	{
		try
		{
			int nlenth = Detector.msDetectorPara.Mass.Length;
			if (AnalogMode == 1)
			{
				for (int a = 0; a < nlenth; a++)
				{
					Detector.msDetectorPara.IntesnsityAnalog[a] = Detector.msDetectorPara.IntesnsityAnalog[a] * Detector.Instance.dacPAFactors[a * 100];
				}
			}
			int j;
			for (j = 0; j < 16; j++)
			{
				TuneIsotopeAdjustor isotope2 = tuneList.tuneIsotopeList[j];
				if (isotope2.enable)
				{
					isotope2.countsAnalog = GetMassData(isotope2, Detector.msDetectorPara.IntesnsityAnalog);
					isotope2.counts = GetMassData(isotope2, Detector.msDetectorPara.IntesnsityPulse);
					tuneStables[j].Add(isotope2.counts);
					isotope2.stable = tuneStables[j].Stable;
					Invoke((EventHandler)delegate
					{
						dgvTuneIsotopes.InvalidateRow(j);
					});
				}
			}
			int i;
			for (i = 0; i < 4; i++)
			{
				TuneRatio ratio = tuneList.tuneRatioList[i];
				if (ratio.Visible && ratio.NumeratorSym != null && ratio.DenominatorSym != null)
				{
					double numerator = double.NaN;
					double denominator = double.NaN;
					IEnumerable<int> count1 = from isotope in tuneList.tuneIsotopeList
						where isotope.symbol == ratio.NumeratorSym && isotope.enable
						select isotope.counts;
					if (count1 != null && count1.Count() > 0)
					{
						numerator = count1.First();
					}
					IEnumerable<int> count2 = from isotope in tuneList.tuneIsotopeList
						where isotope.symbol == ratio.DenominatorSym && isotope.enable
						select isotope.counts;
					if (count2 != null && count2.Count() > 0)
					{
						denominator = count2.First();
					}
					if (!double.IsNaN(numerator) && !double.IsNaN(denominator))
					{
						ratio.Ratio = numerator / denominator;
						ratioStables[i].Add(ratio.Ratio);
						ratio.Stability = ratioStables[i].Stable;
					}
				}
				Invoke((EventHandler)delegate
				{
					dgvTuneRatio.InvalidateRow(i);
				});
			}
		}
		catch (Exception ex)
		{
			Log.InsertLog("Tune", "Calculating scanned data", ex.Message, (Severity)3);
		}
	}

	private int GetMassData(TuneIsotopeAdjustor isotope, double[] masses)
	{
		double[] massAxis = Detector.msDetectorPara.Mass;
		double left = isotope.mass - 0.45;
		double right = isotope.mass + 0.55;
		try
		{
			if (masses.Where((double data, int index) => massAxis[index] >= left && massAxis[index] <= right).Count() == 0)
			{
				return 0;
			}
			return (int)masses.Where((double data, int index) => massAxis[index] >= left && massAxis[index] <= right).Average();
		}
		catch (Exception ex)
		{
			Log.InsertLog("Tune", "Data processing error", ex.Message, (Severity)3);
			return 0;
		}
	}

	private void MassDetector_msTuneEventhandler(object sender, EventArgs e)
	{
		scanEvent.Set();
	}

	private void DrawCurve()
	{
		for (int k = 0; k < tuneList.tuneIsotopeList.Count; k++)
		{
			if (tuneList.tuneIsotopeList[k].enable)
			{
				double datetime = new XDate(DateTime.Now);
				paneArray[0].CurveList[k].AddPoint(datetime, tuneList.tuneIsotopeList[k].counts);
				paneArray1[0].CurveList[k].AddPoint(datetime, tuneList.tuneIsotopeList[k].countsAnalog);
			}
		}
		if (graphControlTuneGraph.MasterPane.PaneList[0].Equals(paneArray[1]))
		{
			ClearPane1();
			for (int j = 0; j < tuneList.tuneIsotopeList.Count; j++)
			{
				if (tuneList.tuneIsotopeList[j].enable)
				{
					paneArray[1].CurveList[0].AddPoint(tuneList.tuneIsotopeList[j].mass, tuneList.tuneIsotopeList[j].counts);
				}
			}
		}
		if (!graphControlTuneGraph.MasterPane.PaneList[1].Equals(paneArray1[1]))
		{
			return;
		}
		ClearPane1();
		for (int i = 0; i < tuneList.tuneIsotopeList.Count; i++)
		{
			if (tuneList.tuneIsotopeList[i].enable)
			{
				paneArray1[1].CurveList[0].AddPoint(tuneList.tuneIsotopeList[i].mass, tuneList.tuneIsotopeList[i].countsAnalog);
			}
		}
	}

	private void RefreshTuneGraph()
	{
		Invoke((MethodInvoker)delegate
		{
			try
			{
				using Graphics g = graphControlTuneGraph.CreateGraphics();
				graphControlTuneGraph.MasterPane.SetLayout(g, PaneLayout.SingleRow);
				graphControlTuneGraph.MasterPane.AxisChange(g);
				graphControlTuneGraph.Refresh();
			}
			catch
			{
			}
		});
	}

	private void toolStripComboBoxInstrumentSetupGraphShowMode_SelectedIndexChanged(object sender, EventArgs e)
	{
		paneArray[tscbPaneMode.SelectedIndex].Rect = graphControlTuneGraph.MasterPane.PaneList[0].Rect;
		graphControlTuneGraph.MasterPane.PaneList[0] = paneArray[tscbPaneMode.SelectedIndex];
		paneArray1[tscbPaneMode.SelectedIndex].Rect = graphControlTuneGraph.MasterPane.PaneList[0].Rect;
		graphControlTuneGraph.MasterPane.PaneList[1] = paneArray1[tscbPaneMode.SelectedIndex];
		RefreshTuneGraph();
	}

	private void setupTuneGraphCurve()
	{
		graphControlTuneGraph.MasterPane.PaneList.Clear();
		paneArray[0] = new GraphPane();
		paneArray[1] = new GraphPane();
		paneArray[2] = new GraphPane();
		paneArray[0].Title.Text = Lang.Txt("ADDTune.TuneDebug.PCCount");
		paneArray[0].XAxis.Title.Text = Lang.Txt("FormInstrumentTune.Graph.X.Time.Text");
		paneArray[0].YAxis.Title.Text = Lang.Txt("FormInstrumentTune.Graph.Y.Intensity.Text");
		paneArray[1].Title.Text = Lang.Txt("ADDTune.TuneDebug.PCCount");
		paneArray[1].XAxis.Title.Text = Lang.Txt("FormInstrumentTune.Graph.X.Mass.Text");
		paneArray[1].YAxis.Title.Text = Lang.Txt("FormInstrumentTune.Graph.Y.Intensity.Text");
		paneArray[2].Title.Text = Lang.Txt("ADDTune.TuneDebug.PCCount");
		paneArray[2].XAxis.Title.Text = Lang.Txt("FormInstrumentTune.Graph.X.Mass.Text");
		paneArray[2].YAxis.Title.Text = Lang.Txt("FormInstrumentTune.Graph.Y.Intensity.Text");
		paneArray[2].XAxis.Scale.Min = 0.0;
		paneArray[2].XAxis.Scale.Max = 300.0;
		graphControlTuneGraph.MasterPane.Add(paneArray[0]);
		paneArray1[0] = new GraphPane();
		paneArray1[1] = new GraphPane();
		paneArray1[2] = new GraphPane();
		paneArray1[0].Title.Text = Lang.Txt("ADDTune.TuneDebug.AnalogCount");
		paneArray1[0].XAxis.Title.Text = Lang.Txt("FormInstrumentTune.Graph.X.Time.Text");
		paneArray1[0].YAxis.Title.Text = Lang.Txt("FormInstrumentTune.Graph.Y.Intensity.Text");
		paneArray1[1].Title.Text = Lang.Txt("ADDTune.TuneDebug.AnalogCount");
		paneArray1[1].XAxis.Title.Text = Lang.Txt("FormInstrumentTune.Graph.X.Mass.Text");
		paneArray1[1].YAxis.Title.Text = Lang.Txt("FormInstrumentTune.Graph.Y.Intensity.Text");
		paneArray1[2].Title.Text = Lang.Txt("ADDTune.TuneDebug.AnalogCount");
		paneArray1[2].XAxis.Title.Text = Lang.Txt("FormInstrumentTune.Graph.X.Mass.Text");
		paneArray1[2].YAxis.Title.Text = Lang.Txt("FormInstrumentTune.Graph.Y.Intensity.Text");
		paneArray1[2].XAxis.Scale.Min = 0.0;
		paneArray1[2].XAxis.Scale.Max = 300.0;
		graphControlTuneGraph.MasterPane.Add(paneArray1[0]);
		SetupPane0();
		SetupPane1();
		RefreshTuneGraph();
	}

	private void SetupPane0()
	{
		paneArray[0].CurveList.Clear();
		paneArray1[0].CurveList.Clear();
		for (int i = 0; i < 16; i++)
		{
			LineItem line = paneArray[0].AddCurve(null, new PointPairList(), Color.FromArgb(tuneList.tuneIsotopeList[i].color), SymbolType.None);
			line.Line.Width = 2f;
			line.IsVisible = tuneList.tuneIsotopeList[i].visible;
			line.Tag = tuneList.tuneIsotopeList[i].symbol;
			LineItem line2 = paneArray1[0].AddCurve(null, new PointPairList(), Color.FromArgb(tuneList.tuneIsotopeList[i].color), SymbolType.None);
			line2.Line.Width = 2f;
			line2.Tag = tuneList.tuneIsotopeList[i].symbol;
			line2.IsVisible = tuneList.tuneIsotopeList[i].visible;
		}
		paneArray[0].XAxis.Scale.Min = new XDate(DateTime.Now);
		paneArray[0].YAxis.Scale.MaxAuto = true;
		paneArray[0].YAxis.Scale.MinAuto = true;
		paneArray[0].XAxis.MinorGrid.IsVisible = false;
		paneArray[0].XAxis.MajorGrid.IsVisible = false;
		paneArray[0].XAxis.Scale.Format = "HH:mm:ss";
		paneArray[0].XAxis.Type = AxisType.Date;
		paneArray1[0].XAxis.Scale.Min = new XDate(DateTime.Now);
		paneArray1[0].YAxis.Scale.MaxAuto = true;
		paneArray1[0].YAxis.Scale.MinAuto = true;
		paneArray1[0].XAxis.MinorGrid.IsVisible = false;
		paneArray1[0].XAxis.MajorGrid.IsVisible = false;
		paneArray1[0].XAxis.Scale.Format = "HH:mm:ss";
		paneArray1[0].XAxis.Type = AxisType.Date;
	}

	private void ClearPane0()
	{
		for (int i = 0; i < 16; i++)
		{
			paneArray[0].CurveList[i].Clear();
			paneArray1[0].CurveList[i].Clear();
		}
		paneArray[0].XAxis.Scale.Min = new XDate(DateTime.Now);
		paneArray1[0].XAxis.Scale.Min = new XDate(DateTime.Now);
	}

	private void ShowlineofPane(int line, bool visible)
	{
		paneArray[0].CurveList[line].IsVisible = visible;
		paneArray1[0].CurveList[line].IsVisible = visible;
		RefreshTuneGraph();
	}

	private void SetupPane1()
	{
		paneArray[1].CurveList.Clear();
		LineItem line = paneArray[1].AddCurve(null, new PointPairList(), Color.Blue, SymbolType.Circle);
		line.Symbol.Fill.Type = FillType.Solid;
		line.Line.IsVisible = false;
		paneArray[1].XAxis.Scale.Min = 4.0;
		paneArray[1].XAxis.Scale.Max = 265.0;
		paneArray[1].YAxis.Scale.MaxAuto = true;
		paneArray[1].YAxis.Scale.Min = 0.0;
		paneArray[1].YAxis.MajorGrid.IsVisible = true;
		paneArray[1].YAxis.MinorGrid.IsVisible = true;
		paneArray1[1].CurveList.Clear();
		LineItem line2 = paneArray1[1].AddCurve(null, new PointPairList(), Color.Blue, SymbolType.Circle);
		line2.Symbol.Fill.Type = FillType.Solid;
		line2.Line.IsVisible = false;
		paneArray1[1].XAxis.Scale.Min = 4.0;
		paneArray1[1].XAxis.Scale.Max = 265.0;
		paneArray1[1].YAxis.Scale.MaxAuto = true;
		paneArray1[1].YAxis.Scale.Min = 0.0;
		paneArray1[1].YAxis.MajorGrid.IsVisible = true;
		paneArray1[1].YAxis.MinorGrid.IsVisible = true;
	}

	private void ClearPane1()
	{
		paneArray[1].CurveList[0].Clear();
		paneArray1[1].CurveList[0].Clear();
	}

	private void ThreadRefresh()
	{
		while (!tuneStop)
		{
			RefreshTuneGraph();
			Thread.Sleep(200);
		}
	}

	private void tsmiRunAutotune_Click(object sender, EventArgs e)
	{
		tsbtnStop.PerformClick();
		if (!FormNewAutoTuneRunWizard.IsOpen)
		{
			EnableTune(bEnable: false);
			FormNewAutoTuneRunWizard dlg = new FormNewAutoTuneRunWizard();
			dlg.FormClosed += delegate
			{
				EnableTune(bEnable: true);
			};
			dlg.Show();
		}
	}

	private void tsmiEditAutoTune_Click(object sender, EventArgs e)
	{
		tsbtnStop.PerformClick();
		FormNewAutoTuneEditWizard dlg = new FormNewAutoTuneEditWizard();
		dlg.ShowDialog();
	}

	private void tsbtnAutoTune_ButtonClick(object sender, EventArgs e)
	{
		tsmiRunAutotune_Click(null, null);
	}

	private void EnableTune(bool bEnable)
	{
	}

	private void toolStripButton3_Click(object sender, EventArgs e)
	{
		Task.Factory.StartNew(delegate
		{
			StreamWriter streamWriter = null;
			string value = "";
			SaveFileDialog saveFileDialog = new SaveFileDialog
			{
				Filter = "CSV文件|*.csv",
				DefaultExt = "*.csv"
			};
			string fileName = saveFileDialog.FileName;
			if (saveFileDialog.ShowDialog() == DialogResult.OK)
			{
				GraphPane graphPane = graphControlTuneGraph.MasterPane.PaneList[0];
				GraphPane graphPane2 = graphControlTuneGraph.MasterPane.PaneList[1];
				for (int i = 0; i < graphPane.CurveList.Count(); i++)
				{
					value = "Time," + tuneList.tuneIsotopeList[i].symbol.ToString() + "(PC)," + tuneList.tuneIsotopeList[i].symbol.ToString() + "(Analog)\r\n";
					CurveItem curveItem = graphPane.CurveList[i];
					CurveItem curveItem2 = graphPane2.CurveList[i];
					for (int j = 0; j < curveItem.Points.Count; j++)
					{
						value = curveItem.Points[j].X.ToString("yyyy-MM-dd HH:mm:ss") + "," + curveItem.Points[j].Y + "," + curveItem2.Points[j].Y + "\r\n";
					}
				}
				streamWriter = new StreamWriter(saveFileDialog.FileName);
				streamWriter.Write(value);
				streamWriter.Close();
			}
		});
	}

	private void tscbAnalog_SelectedIndexChanged(object sender, EventArgs e)
	{
		AnalogMode = tscbAnalog.SelectedIndex;
	}

	private void toolStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
	{
	}

	private void dgvTuneIsotopes_CurrentCellChanged(object sender, EventArgs e)
	{
		DataGridView dgv = sender as DataGridView;
		if (dgv.CurrentCell == null)
		{
			return;
		}
		int rowIndex = dgv.CurrentCell.RowIndex;
		int columnIndex = dgv.CurrentCell.ColumnIndex;
		string dataPropertyName = dgv.Columns[columnIndex].DataPropertyName;
		string text = dataPropertyName;
		if (text == "resolution")
		{
			cbDgvEdit = new ComboBox();
			cbDgvEdit.DropDownStyle = ComboBoxStyle.DropDownList;
			cbDgvEdit.Parent = dgv;
			cbDgvEdit.Items.Clear();
			Rectangle rect = dgv.GetCellDisplayRectangle(columnIndex, rowIndex, cutOverflow: false);
			cbDgvEdit.Left = rect.Left;
			cbDgvEdit.Top = rect.Top;
			cbDgvEdit.Width = rect.Width;
			cbDgvEdit.Height = rect.Height;
			cbDgvEdit.Items.Add(Lang.Txt("ADDTune.TuneDebug.Normal"));
			cbDgvEdit.Items.Add(Lang.Txt("ADDTune.TuneDebug.High"));
			cbDgvEdit.Items.Add(Lang.Txt("ADDTune.TuneDebug.Low"));
			cbDgvEdit.SelectedItem = dgv.CurrentCell.Value.ToString();
			cbDgvEdit.SelectedIndexChanged += delegate
			{
				tuneList.tuneIsotopeList[rowIndex].resolution = ((cbDgvEdit.SelectedItem.ToString() == Lang.Txt("FormScanLA.Standard")) ? 1 : ((!(cbDgvEdit.SelectedItem.ToString() == Lang.Txt("ADDTune.TuneDebug.High"))) ? 2 : 0));
				dgv.InvalidateCell(columnIndex, rowIndex);
			};
			cbDgvEdit.Visible = true;
		}
	}

	private void dgvTuneIsotopes_CellLeave(object sender, DataGridViewCellEventArgs e)
	{
		if (cbDgvEdit != null)
		{
			cbDgvEdit.Visible = false;
			cbDgvEdit.Dispose();
		}
	}

	private void dgvTuneIsotopes_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
	{
		if (e.RowIndex == -1 || e.Button == MouseButtons.Left)
		{
			return;
		}
		ContextMenu menu = new ContextMenu();
		menu.MenuItems.Add(Lang.Txt("FormScanNCS.Menu.Order.Text"), delegate
		{
			if (dgvTuneIsotopes.SelectedCells != null && dgvTuneIsotopes.SelectedCells.Count > 0)
			{
				tuneList.tuneIsotopeList.Sort((TuneIsotopeAdjustor left, TuneIsotopeAdjustor right) => (int)((left.mass - right.mass) * 1000.0));
				dgvTuneIsotopes.DataSource = tuneList.tuneIsotopeList;
				dgvTuneIsotopes.Refresh();
				dgvTuneIsotopes.Columns["id"].Visible = false;
				dgvTuneIsotopes.Columns["atom"].Visible = false;
				dgvTuneIsotopes.Columns["countsAnalog"].Visible = false;
				colAMUTune.HeaderText = Lang.Txt("FormInstrumentTune.Columns.Mass.Text");
				colChannelsTune.HeaderText = Lang.Txt("FormInstrumentTune.Columns.Channel.Text");
				colColorTune.HeaderText = Lang.Txt("FormInstrumentTune.Columns.Color.Text");
				colCountsTune.HeaderText = Lang.Txt("FormInstrumentTune.Columns.CPS.Text");
				colEnableTune.HeaderText = Lang.Txt("FormInstrumentTune.Columns.Open.Text");
				colSpacingTune.HeaderText = Lang.Txt("FormInstrumentTune.Columns.gap.Text");
				colStableTune.HeaderText = Lang.Txt("FormInstrumentTune.Columns.Stable.Text");
				colSymbolTune.HeaderText = Lang.Txt("FormInstrumentTune.Columns.Symbol.Text");
				colVisibleTune.HeaderText = Lang.Txt("FormInstrumentTune.Columns.Visible.Text");
				if (!tuneStop)
				{
					bConfigChanged = true;
				}
			}
		});
		Rectangle rect = dgvTuneIsotopes.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, cutOverflow: false);
		Point pt = e.Location;
		pt.Offset(rect.X, rect.Y);
		menu.Show(dgvTuneIsotopes, pt);
	}

	protected override void Dispose(bool disposing)
	{
		if (disposing && components != null)
		{
			components.Dispose();
		}
		base.Dispose(disposing);
	}

	private void InitializeComponent()
	{
		this.components = new System.ComponentModel.Container();
		System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
		System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle12 = new System.Windows.Forms.DataGridViewCellStyle();
		System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle23 = new System.Windows.Forms.DataGridViewCellStyle();
		System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle();
		System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle34 = new System.Windows.Forms.DataGridViewCellStyle();
		System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle35 = new System.Windows.Forms.DataGridViewCellStyle();
		System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle36 = new System.Windows.Forms.DataGridViewCellStyle();
		System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle37 = new System.Windows.Forms.DataGridViewCellStyle();
		System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle38 = new System.Windows.Forms.DataGridViewCellStyle();
		System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle39 = new System.Windows.Forms.DataGridViewCellStyle();
		System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
		System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
		System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();
		System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle();
		System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle();
		System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle();
		System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle9 = new System.Windows.Forms.DataGridViewCellStyle();
		System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle10 = new System.Windows.Forms.DataGridViewCellStyle();
		System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle11 = new System.Windows.Forms.DataGridViewCellStyle();
		System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle13 = new System.Windows.Forms.DataGridViewCellStyle();
		System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle14 = new System.Windows.Forms.DataGridViewCellStyle();
		System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle15 = new System.Windows.Forms.DataGridViewCellStyle();
		System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle16 = new System.Windows.Forms.DataGridViewCellStyle();
		System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle17 = new System.Windows.Forms.DataGridViewCellStyle();
		System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle18 = new System.Windows.Forms.DataGridViewCellStyle();
		System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle19 = new System.Windows.Forms.DataGridViewCellStyle();
		System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle20 = new System.Windows.Forms.DataGridViewCellStyle();
		System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle21 = new System.Windows.Forms.DataGridViewCellStyle();
		System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle22 = new System.Windows.Forms.DataGridViewCellStyle();
		System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle24 = new System.Windows.Forms.DataGridViewCellStyle();
		System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle25 = new System.Windows.Forms.DataGridViewCellStyle();
		System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle26 = new System.Windows.Forms.DataGridViewCellStyle();
		System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle27 = new System.Windows.Forms.DataGridViewCellStyle();
		System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle28 = new System.Windows.Forms.DataGridViewCellStyle();
		System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle29 = new System.Windows.Forms.DataGridViewCellStyle();
		System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle30 = new System.Windows.Forms.DataGridViewCellStyle();
		System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle31 = new System.Windows.Forms.DataGridViewCellStyle();
		System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle32 = new System.Windows.Forms.DataGridViewCellStyle();
		System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle33 = new System.Windows.Forms.DataGridViewCellStyle();
		System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ICP_MS.Plugin.Tune.FormInstrumentTuneDebug));
		this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
		this.panel1 = new System.Windows.Forms.Panel();
		this.tableLayoutPanel4 = new System.Windows.Forms.TableLayoutPanel();
		this.dgvTuneRatio = new System.Windows.Forms.DataGridView();
		this.colRatioColor = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.colRatioNumerator = new System.Windows.Forms.DataGridViewComboBoxColumn();
		this.colRatioDenominator = new System.Windows.Forms.DataGridViewComboBoxColumn();
		this.colRatioVisible = new System.Windows.Forms.DataGridViewCheckBoxColumn();
		this.colRatio = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.colRatioStable = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.dgvTuneIsotopes = new System.Windows.Forms.DataGridView();
		this.colColorTune = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.colSymbolTune = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.colAMUTune = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.colEnableTune = new System.Windows.Forms.DataGridViewCheckBoxColumn();
		this.colVisibleTune = new System.Windows.Forms.DataGridViewCheckBoxColumn();
		this.colSpacingTune = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.colDwellTune = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.colChannelsTune = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.colResolution = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.colCountsTune = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.colStableTune = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.toolStrip1 = new System.Windows.Forms.ToolStrip();
		this.toolStripSeparator5 = new System.Windows.Forms.ToolStripSeparator();
		this.tsbtnSetupRun = new System.Windows.Forms.ToolStripButton();
		this.tsbtnStop = new System.Windows.Forms.ToolStripButton();
		this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator();
		this.tscbPaneMode = new System.Windows.Forms.ToolStripComboBox();
		this.tscbAnalog = new System.Windows.Forms.ToolStripComboBox();
		this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.dataGridViewTextBoxColumn2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.dataGridViewTextBoxColumn3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.dataGridViewTextBoxColumn4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.dataGridViewTextBoxColumn5 = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.dataGridViewTextBoxColumn6 = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.dataGridViewTextBoxColumn7 = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.dataGridViewTextBoxColumn8 = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.dataGridViewTextBoxColumn9 = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.dataGridViewTextBoxColumn10 = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.dataGridViewTextBoxColumn11 = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.dataGridViewTextBoxColumn12 = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.dataGridViewTextBoxColumn13 = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.dataGridViewTextBoxColumn14 = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.dataGridViewTextBoxColumn15 = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.dataGridViewTextBoxColumn16 = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.dataGridViewTextBoxColumn17 = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.dataGridViewTextBoxColumn18 = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.dataGridViewTextBoxColumn19 = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.dataGridViewTextBoxColumn20 = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.dataGridViewTextBoxColumn21 = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.dataGridViewTextBoxColumn22 = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.dataGridViewTextBoxColumn23 = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.dataGridViewTextBoxColumn24 = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.dataGridViewTextBoxColumn25 = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.dataGridViewTextBoxColumn26 = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.dataGridViewTextBoxColumn27 = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.graphControlTuneGraph = new ZedGraph.ZedGraphControl();
		this.tableLayoutPanel1.SuspendLayout();
		this.panel1.SuspendLayout();
		this.tableLayoutPanel4.SuspendLayout();
		((System.ComponentModel.ISupportInitialize)this.dgvTuneRatio).BeginInit();
		((System.ComponentModel.ISupportInitialize)this.dgvTuneIsotopes).BeginInit();
		this.toolStrip1.SuspendLayout();
		base.SuspendLayout();
		this.tableLayoutPanel1.ColumnCount = 1;
		this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
		this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 27f));
		this.tableLayoutPanel1.Controls.Add(this.panel1, 0, 1);
		this.tableLayoutPanel1.Controls.Add(this.tableLayoutPanel4, 0, 0);
		this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
		this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 28);
		this.tableLayoutPanel1.Margin = new System.Windows.Forms.Padding(4);
		this.tableLayoutPanel1.Name = "tableLayoutPanel1";
		this.tableLayoutPanel1.RowCount = 2;
		this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 49.07275f));
		this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50.92725f));
		this.tableLayoutPanel1.Size = new System.Drawing.Size(1153, 880);
		this.tableLayoutPanel1.TabIndex = 1;
		this.panel1.Controls.Add(this.graphControlTuneGraph);
		this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
		this.panel1.Location = new System.Drawing.Point(4, 435);
		this.panel1.Margin = new System.Windows.Forms.Padding(4);
		this.panel1.Name = "panel1";
		this.panel1.Size = new System.Drawing.Size(1145, 441);
		this.panel1.TabIndex = 0;
		this.tableLayoutPanel4.ColumnCount = 1;
		this.tableLayoutPanel4.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100f));
		this.tableLayoutPanel4.Controls.Add(this.dgvTuneRatio, 0, 1);
		this.tableLayoutPanel4.Controls.Add(this.dgvTuneIsotopes, 0, 0);
		this.tableLayoutPanel4.Dock = System.Windows.Forms.DockStyle.Fill;
		this.tableLayoutPanel4.Location = new System.Drawing.Point(4, 4);
		this.tableLayoutPanel4.Margin = new System.Windows.Forms.Padding(4);
		this.tableLayoutPanel4.Name = "tableLayoutPanel4";
		this.tableLayoutPanel4.RowCount = 2;
		this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100f));
		this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 125f));
		this.tableLayoutPanel4.Size = new System.Drawing.Size(1145, 423);
		this.tableLayoutPanel4.TabIndex = 3;
		this.dgvTuneRatio.AllowUserToAddRows = false;
		this.dgvTuneRatio.AllowUserToDeleteRows = false;
		this.dgvTuneRatio.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
		this.dgvTuneRatio.BackgroundColor = System.Drawing.SystemColors.Control;
		dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
		dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control;
		dataGridViewCellStyle1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 134);
		dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText;
		dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight;
		dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
		dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
		this.dgvTuneRatio.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
		this.dgvTuneRatio.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
		this.dgvTuneRatio.Columns.AddRange(this.colRatioColor, this.colRatioNumerator, this.colRatioDenominator, this.colRatioVisible, this.colRatio, this.colRatioStable);
		this.dgvTuneRatio.Dock = System.Windows.Forms.DockStyle.Fill;
		this.dgvTuneRatio.Location = new System.Drawing.Point(4, 302);
		this.dgvTuneRatio.Margin = new System.Windows.Forms.Padding(4);
		this.dgvTuneRatio.MultiSelect = false;
		this.dgvTuneRatio.Name = "dgvTuneRatio";
		this.dgvTuneRatio.RowHeadersVisible = false;
		this.dgvTuneRatio.RowHeadersWidth = 51;
		dataGridViewCellStyle12.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
		this.dgvTuneRatio.RowsDefaultCellStyle = dataGridViewCellStyle12;
		this.dgvTuneRatio.RowTemplate.Height = 23;
		this.dgvTuneRatio.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect;
		this.dgvTuneRatio.Size = new System.Drawing.Size(1137, 117);
		this.dgvTuneRatio.TabIndex = 5;
		this.dgvTuneRatio.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(dgvTuneRatio_CellDoubleClick);
		this.dgvTuneRatio.CellFormatting += new System.Windows.Forms.DataGridViewCellFormattingEventHandler(dgvTuneRatio_CellFormatting);
		this.dgvTuneRatio.CellValueChanged += new System.Windows.Forms.DataGridViewCellEventHandler(dgvTuneRatio_CellValueChanged);
		this.dgvTuneRatio.KeyDown += new System.Windows.Forms.KeyEventHandler(dgvTuneRatio_KeyDown);
		this.colRatioColor.DataPropertyName = "Color";
		this.colRatioColor.FillWeight = 108.0203f;
		this.colRatioColor.HeaderText = "颜色";
		this.colRatioColor.MinimumWidth = 6;
		this.colRatioColor.Name = "colRatioColor";
		this.colRatioColor.ReadOnly = true;
		this.colRatioNumerator.DataPropertyName = "NumeratorSym";
		this.colRatioNumerator.DisplayStyle = System.Windows.Forms.DataGridViewComboBoxDisplayStyle.Nothing;
		this.colRatioNumerator.FillWeight = 90.39594f;
		this.colRatioNumerator.HeaderText = "分子";
		this.colRatioNumerator.MinimumWidth = 6;
		this.colRatioNumerator.Name = "colRatioNumerator";
		this.colRatioNumerator.Resizable = System.Windows.Forms.DataGridViewTriState.True;
		this.colRatioNumerator.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
		this.colRatioDenominator.DataPropertyName = "DenominatorSym";
		this.colRatioDenominator.DisplayStyle = System.Windows.Forms.DataGridViewComboBoxDisplayStyle.Nothing;
		this.colRatioDenominator.FillWeight = 90.39594f;
		this.colRatioDenominator.HeaderText = "分母";
		this.colRatioDenominator.MinimumWidth = 6;
		this.colRatioDenominator.Name = "colRatioDenominator";
		this.colRatioDenominator.Resizable = System.Windows.Forms.DataGridViewTriState.True;
		this.colRatioDenominator.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
		this.colRatioVisible.DataPropertyName = "Visible";
		this.colRatioVisible.FillWeight = 90.39594f;
		this.colRatioVisible.HeaderText = "显示";
		this.colRatioVisible.MinimumWidth = 6;
		this.colRatioVisible.Name = "colRatioVisible";
		this.colRatioVisible.Resizable = System.Windows.Forms.DataGridViewTriState.True;
		this.colRatioVisible.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
		this.colRatio.DataPropertyName = "Ratio";
		this.colRatio.FillWeight = 90.39594f;
		this.colRatio.HeaderText = "比率";
		this.colRatio.MinimumWidth = 6;
		this.colRatio.Name = "colRatio";
		this.colRatio.ReadOnly = true;
		this.colRatioStable.DataPropertyName = "Stability";
		this.colRatioStable.FillWeight = 90.39594f;
		this.colRatioStable.HeaderText = "稳定性";
		this.colRatioStable.MinimumWidth = 6;
		this.colRatioStable.Name = "colRatioStable";
		this.colRatioStable.ReadOnly = true;
		this.dgvTuneIsotopes.AllowUserToAddRows = false;
		this.dgvTuneIsotopes.AllowUserToDeleteRows = false;
		this.dgvTuneIsotopes.AllowUserToResizeRows = false;
		this.dgvTuneIsotopes.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
		this.dgvTuneIsotopes.BackgroundColor = System.Drawing.SystemColors.Control;
		dataGridViewCellStyle23.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
		dataGridViewCellStyle23.BackColor = System.Drawing.SystemColors.Control;
		dataGridViewCellStyle23.Font = new System.Drawing.Font("Microsoft Sans Serif", 9f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 134);
		dataGridViewCellStyle23.ForeColor = System.Drawing.SystemColors.WindowText;
		dataGridViewCellStyle23.SelectionBackColor = System.Drawing.SystemColors.Highlight;
		dataGridViewCellStyle23.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
		dataGridViewCellStyle23.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
		this.dgvTuneIsotopes.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle23;
		this.dgvTuneIsotopes.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
		this.dgvTuneIsotopes.Columns.AddRange(this.colColorTune, this.colSymbolTune, this.colAMUTune, this.colEnableTune, this.colVisibleTune, this.colSpacingTune, this.colDwellTune, this.colChannelsTune, this.colResolution, this.colCountsTune, this.colStableTune);
		this.dgvTuneIsotopes.Dock = System.Windows.Forms.DockStyle.Fill;
		this.dgvTuneIsotopes.Location = new System.Drawing.Point(4, 4);
		this.dgvTuneIsotopes.Margin = new System.Windows.Forms.Padding(4);
		this.dgvTuneIsotopes.MultiSelect = false;
		this.dgvTuneIsotopes.Name = "dgvTuneIsotopes";
		dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
		dataGridViewCellStyle5.BackColor = System.Drawing.SystemColors.Control;
		dataGridViewCellStyle5.Font = new System.Drawing.Font("宋体", 9f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 134);
		dataGridViewCellStyle5.ForeColor = System.Drawing.SystemColors.WindowText;
		dataGridViewCellStyle5.SelectionBackColor = System.Drawing.SystemColors.Highlight;
		dataGridViewCellStyle5.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
		dataGridViewCellStyle5.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
		this.dgvTuneIsotopes.RowHeadersDefaultCellStyle = dataGridViewCellStyle5;
		this.dgvTuneIsotopes.RowHeadersVisible = false;
		this.dgvTuneIsotopes.RowHeadersWidth = 60;
		this.dgvTuneIsotopes.RowTemplate.Height = 23;
		this.dgvTuneIsotopes.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect;
		this.dgvTuneIsotopes.Size = new System.Drawing.Size(1137, 290);
		this.dgvTuneIsotopes.TabIndex = 3;
		this.dgvTuneIsotopes.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(dataGridViewTuneIsotopes_CellDoubleClick);
		this.dgvTuneIsotopes.CellFormatting += new System.Windows.Forms.DataGridViewCellFormattingEventHandler(dgvTuneIsotopes_CellFormatting);
		this.dgvTuneIsotopes.CellLeave += new System.Windows.Forms.DataGridViewCellEventHandler(dgvTuneIsotopes_CellLeave);
		this.dgvTuneIsotopes.CellMouseDown += new System.Windows.Forms.DataGridViewCellMouseEventHandler(dgvTuneIsotopes_CellMouseDown);
		this.dgvTuneIsotopes.CellValueChanged += new System.Windows.Forms.DataGridViewCellEventHandler(dataGridViewTuneIsotopes_CellValueChanged);
		this.dgvTuneIsotopes.CurrentCellChanged += new System.EventHandler(dgvTuneIsotopes_CurrentCellChanged);
		this.dgvTuneIsotopes.CurrentCellDirtyStateChanged += new System.EventHandler(dgvTuneIsotopes_CurrentCellDirtyStateChanged);
		this.dgvTuneIsotopes.KeyDown += new System.Windows.Forms.KeyEventHandler(dgvTuneIsotopes_KeyDown);
		this.colColorTune.DataPropertyName = "color";
		dataGridViewCellStyle34.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
		this.colColorTune.DefaultCellStyle = dataGridViewCellStyle34;
		this.colColorTune.FillWeight = 60f;
		this.colColorTune.HeaderText = "颜色";
		this.colColorTune.MinimumWidth = 6;
		this.colColorTune.Name = "colColorTune";
		this.colColorTune.ReadOnly = true;
		this.colColorTune.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
		this.colSymbolTune.DataPropertyName = "symbol";
		dataGridViewCellStyle35.Alignment = System.Windows.Forms.DataGridViewContentAlignment.TopCenter;
		this.colSymbolTune.DefaultCellStyle = dataGridViewCellStyle35;
		this.colSymbolTune.HeaderText = "符号";
		this.colSymbolTune.MinimumWidth = 6;
		this.colSymbolTune.Name = "colSymbolTune";
		this.colSymbolTune.ReadOnly = true;
		this.colSymbolTune.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
		this.colAMUTune.DataPropertyName = "mass";
		dataGridViewCellStyle36.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
		this.colAMUTune.DefaultCellStyle = dataGridViewCellStyle36;
		this.colAMUTune.HeaderText = "质量数(AMU)";
		this.colAMUTune.MinimumWidth = 6;
		this.colAMUTune.Name = "colAMUTune";
		this.colAMUTune.ReadOnly = true;
		this.colAMUTune.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
		this.colEnableTune.DataPropertyName = "enable";
		this.colEnableTune.HeaderText = "开启";
		this.colEnableTune.MinimumWidth = 6;
		this.colEnableTune.Name = "colEnableTune";
		this.colEnableTune.Resizable = System.Windows.Forms.DataGridViewTriState.True;
		this.colEnableTune.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
		this.colVisibleTune.DataPropertyName = "visible";
		this.colVisibleTune.HeaderText = "显示";
		this.colVisibleTune.MinimumWidth = 6;
		this.colVisibleTune.Name = "colVisibleTune";
		this.colVisibleTune.Resizable = System.Windows.Forms.DataGridViewTriState.True;
		this.colSpacingTune.DataPropertyName = "spacing";
		dataGridViewCellStyle37.Alignment = System.Windows.Forms.DataGridViewContentAlignment.BottomCenter;
		this.colSpacingTune.DefaultCellStyle = dataGridViewCellStyle37;
		this.colSpacingTune.HeaderText = "间距";
		this.colSpacingTune.MinimumWidth = 6;
		this.colSpacingTune.Name = "colSpacingTune";
		this.colDwellTune.DataPropertyName = "dwell";
		dataGridViewCellStyle38.Alignment = System.Windows.Forms.DataGridViewContentAlignment.BottomCenter;
		this.colDwellTune.DefaultCellStyle = dataGridViewCellStyle38;
		this.colDwellTune.HeaderText = "驻留时间(ms)";
		this.colDwellTune.MinimumWidth = 6;
		this.colDwellTune.Name = "colDwellTune";
		this.colDwellTune.ReadOnly = true;
		this.colDwellTune.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
		this.colDwellTune.Visible = false;
		this.colChannelsTune.DataPropertyName = "channels";
		dataGridViewCellStyle39.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
		this.colChannelsTune.DefaultCellStyle = dataGridViewCellStyle39;
		this.colChannelsTune.HeaderText = "通道";
		this.colChannelsTune.MinimumWidth = 6;
		this.colChannelsTune.Name = "colChannelsTune";
		this.colResolution.DataPropertyName = "resolution";
		dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
		this.colResolution.DefaultCellStyle = dataGridViewCellStyle2;
		this.colResolution.HeaderText = "分辨率";
		this.colResolution.MinimumWidth = 6;
		this.colResolution.Name = "colResolution";
		this.colCountsTune.DataPropertyName = "counts";
		dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
		dataGridViewCellStyle3.BackColor = System.Drawing.Color.PaleGreen;
		this.colCountsTune.DefaultCellStyle = dataGridViewCellStyle3;
		this.colCountsTune.HeaderText = "计数(c/s)";
		this.colCountsTune.MinimumWidth = 6;
		this.colCountsTune.Name = "colCountsTune";
		this.colCountsTune.ReadOnly = true;
		this.colCountsTune.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
		this.colStableTune.DataPropertyName = "stable";
		dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.BottomCenter;
		dataGridViewCellStyle4.BackColor = System.Drawing.Color.PaleGreen;
		this.colStableTune.DefaultCellStyle = dataGridViewCellStyle4;
		this.colStableTune.HeaderText = "稳定性(%)";
		this.colStableTune.MinimumWidth = 6;
		this.colStableTune.Name = "colStableTune";
		this.colStableTune.ReadOnly = true;
		this.colStableTune.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
		this.toolStrip1.BackColor = System.Drawing.SystemColors.Control;
		this.toolStrip1.ImageScalingSize = new System.Drawing.Size(20, 20);
		this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[6] { this.toolStripSeparator5, this.tsbtnSetupRun, this.tsbtnStop, this.toolStripSeparator4, this.tscbPaneMode, this.tscbAnalog });
		this.toolStrip1.LayoutStyle = System.Windows.Forms.ToolStripLayoutStyle.HorizontalStackWithOverflow;
		this.toolStrip1.Location = new System.Drawing.Point(0, 0);
		this.toolStrip1.Name = "toolStrip1";
		this.toolStrip1.RenderMode = System.Windows.Forms.ToolStripRenderMode.System;
		this.toolStrip1.Size = new System.Drawing.Size(1153, 28);
		this.toolStrip1.TabIndex = 0;
		this.toolStrip1.Text = "toolStrip1";
		this.toolStrip1.ItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(toolStrip1_ItemClicked);
		this.toolStripSeparator5.Name = "toolStripSeparator5";
		this.toolStripSeparator5.Size = new System.Drawing.Size(6, 28);
		this.tsbtnSetupRun.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
		this.tsbtnSetupRun.Image = ICP_MS.Plugin.Tune.Properties.Resources.TurnRun;
		this.tsbtnSetupRun.ImageTransparentColor = System.Drawing.Color.Magenta;
		this.tsbtnSetupRun.Name = "tsbtnSetupRun";
		this.tsbtnSetupRun.Size = new System.Drawing.Size(29, 25);
		this.tsbtnSetupRun.Text = "设置并扫描";
		this.tsbtnSetupRun.Click += new System.EventHandler(tsbtnSetRun_Click);
		this.tsbtnStop.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
		this.tsbtnStop.Image = ICP_MS.Plugin.Tune.Properties.Resources.TurnStop;
		this.tsbtnStop.ImageTransparentColor = System.Drawing.Color.Magenta;
		this.tsbtnStop.Name = "tsbtnStop";
		this.tsbtnStop.Size = new System.Drawing.Size(29, 25);
		this.tsbtnStop.Text = "停止调谐";
		this.tsbtnStop.Click += new System.EventHandler(toolStripButtonInstrumentSetupStop_Click);
		this.toolStripSeparator4.Name = "toolStripSeparator4";
		this.toolStripSeparator4.Size = new System.Drawing.Size(6, 28);
		this.tscbPaneMode.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
		this.tscbPaneMode.Items.AddRange(new object[2] { "时间/强度模式", "质量数/强度模式" });
		this.tscbPaneMode.Name = "tscbPaneMode";
		this.tscbPaneMode.Size = new System.Drawing.Size(160, 28);
		this.tscbPaneMode.SelectedIndexChanged += new System.EventHandler(toolStripComboBoxInstrumentSetupGraphShowMode_SelectedIndexChanged);
		this.tscbAnalog.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
		this.tscbAnalog.Items.AddRange(new object[2] { "原始模拟模式", "校正模拟模式" });
		this.tscbAnalog.Name = "tscbAnalog";
		this.tscbAnalog.Size = new System.Drawing.Size(210, 28);
		this.tscbAnalog.SelectedIndexChanged += new System.EventHandler(tscbAnalog_SelectedIndexChanged);
		this.dataGridViewTextBoxColumn1.DataPropertyName = "color";
		dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
		this.dataGridViewTextBoxColumn1.DefaultCellStyle = dataGridViewCellStyle6;
		this.dataGridViewTextBoxColumn1.FillWeight = 60f;
		this.dataGridViewTextBoxColumn1.HeaderText = "颜色";
		this.dataGridViewTextBoxColumn1.MinimumWidth = 6;
		this.dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1";
		this.dataGridViewTextBoxColumn1.ReadOnly = true;
		this.dataGridViewTextBoxColumn1.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
		this.dataGridViewTextBoxColumn1.Width = 40;
		this.dataGridViewTextBoxColumn2.DataPropertyName = "symbol";
		dataGridViewCellStyle7.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
		this.dataGridViewTextBoxColumn2.DefaultCellStyle = dataGridViewCellStyle7;
		this.dataGridViewTextBoxColumn2.HeaderText = "符号";
		this.dataGridViewTextBoxColumn2.MinimumWidth = 6;
		this.dataGridViewTextBoxColumn2.Name = "dataGridViewTextBoxColumn2";
		this.dataGridViewTextBoxColumn2.ReadOnly = true;
		this.dataGridViewTextBoxColumn2.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
		this.dataGridViewTextBoxColumn2.Width = 74;
		this.dataGridViewTextBoxColumn3.DataPropertyName = "mass";
		dataGridViewCellStyle8.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
		this.dataGridViewTextBoxColumn3.DefaultCellStyle = dataGridViewCellStyle8;
		this.dataGridViewTextBoxColumn3.HeaderText = "质量数";
		this.dataGridViewTextBoxColumn3.MinimumWidth = 6;
		this.dataGridViewTextBoxColumn3.Name = "dataGridViewTextBoxColumn3";
		this.dataGridViewTextBoxColumn3.ReadOnly = true;
		this.dataGridViewTextBoxColumn3.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
		this.dataGridViewTextBoxColumn3.Width = 74;
		this.dataGridViewTextBoxColumn4.DataPropertyName = "color";
		dataGridViewCellStyle9.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
		this.dataGridViewTextBoxColumn4.DefaultCellStyle = dataGridViewCellStyle9;
		this.dataGridViewTextBoxColumn4.FillWeight = 60f;
		this.dataGridViewTextBoxColumn4.HeaderText = "驻留时间(ms)";
		this.dataGridViewTextBoxColumn4.MinimumWidth = 6;
		this.dataGridViewTextBoxColumn4.Name = "dataGridViewTextBoxColumn4";
		this.dataGridViewTextBoxColumn4.ReadOnly = true;
		this.dataGridViewTextBoxColumn4.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
		this.dataGridViewTextBoxColumn4.Width = 40;
		this.dataGridViewTextBoxColumn5.DataPropertyName = "symbol";
		dataGridViewCellStyle10.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
		this.dataGridViewTextBoxColumn5.DefaultCellStyle = dataGridViewCellStyle10;
		this.dataGridViewTextBoxColumn5.HeaderText = "符号";
		this.dataGridViewTextBoxColumn5.MinimumWidth = 6;
		this.dataGridViewTextBoxColumn5.Name = "dataGridViewTextBoxColumn5";
		this.dataGridViewTextBoxColumn5.ReadOnly = true;
		this.dataGridViewTextBoxColumn5.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
		this.dataGridViewTextBoxColumn5.Width = 67;
		this.dataGridViewTextBoxColumn6.DataPropertyName = "mass";
		dataGridViewCellStyle11.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
		this.dataGridViewTextBoxColumn6.DefaultCellStyle = dataGridViewCellStyle11;
		this.dataGridViewTextBoxColumn6.HeaderText = "质量数";
		this.dataGridViewTextBoxColumn6.MinimumWidth = 6;
		this.dataGridViewTextBoxColumn6.Name = "dataGridViewTextBoxColumn6";
		this.dataGridViewTextBoxColumn6.ReadOnly = true;
		this.dataGridViewTextBoxColumn6.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
		this.dataGridViewTextBoxColumn6.Width = 68;
		this.dataGridViewTextBoxColumn7.DataPropertyName = "spacing";
		dataGridViewCellStyle13.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
		this.dataGridViewTextBoxColumn7.DefaultCellStyle = dataGridViewCellStyle13;
		this.dataGridViewTextBoxColumn7.HeaderText = "DAC数值";
		this.dataGridViewTextBoxColumn7.MinimumWidth = 6;
		this.dataGridViewTextBoxColumn7.Name = "dataGridViewTextBoxColumn7";
		this.dataGridViewTextBoxColumn7.ReadOnly = true;
		this.dataGridViewTextBoxColumn7.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
		this.dataGridViewTextBoxColumn7.Width = 67;
		this.dataGridViewTextBoxColumn8.DataPropertyName = "dwell";
		dataGridViewCellStyle14.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
		this.dataGridViewTextBoxColumn8.DefaultCellStyle = dataGridViewCellStyle14;
		this.dataGridViewTextBoxColumn8.HeaderText = "峰宽(AMU)";
		this.dataGridViewTextBoxColumn8.MinimumWidth = 6;
		this.dataGridViewTextBoxColumn8.Name = "dataGridViewTextBoxColumn8";
		this.dataGridViewTextBoxColumn8.ReadOnly = true;
		this.dataGridViewTextBoxColumn8.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
		this.dataGridViewTextBoxColumn8.Width = 68;
		this.dataGridViewTextBoxColumn9.DataPropertyName = "channels";
		dataGridViewCellStyle15.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
		this.dataGridViewTextBoxColumn9.DefaultCellStyle = dataGridViewCellStyle15;
		this.dataGridViewTextBoxColumn9.FillWeight = 108.0203f;
		this.dataGridViewTextBoxColumn9.HeaderText = "误差(AMU)";
		this.dataGridViewTextBoxColumn9.MinimumWidth = 6;
		this.dataGridViewTextBoxColumn9.Name = "dataGridViewTextBoxColumn9";
		this.dataGridViewTextBoxColumn9.ReadOnly = true;
		this.dataGridViewTextBoxColumn9.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
		this.dataGridViewTextBoxColumn9.Width = 150;
		this.dataGridViewTextBoxColumn10.DataPropertyName = "counts";
		dataGridViewCellStyle16.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
		this.dataGridViewTextBoxColumn10.DefaultCellStyle = dataGridViewCellStyle16;
		this.dataGridViewTextBoxColumn10.FillWeight = 90.39594f;
		this.dataGridViewTextBoxColumn10.HeaderText = "误差(AMU)";
		this.dataGridViewTextBoxColumn10.MinimumWidth = 6;
		this.dataGridViewTextBoxColumn10.Name = "dataGridViewTextBoxColumn10";
		this.dataGridViewTextBoxColumn10.ReadOnly = true;
		this.dataGridViewTextBoxColumn10.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
		this.dataGridViewTextBoxColumn10.Width = 120;
		this.dataGridViewTextBoxColumn11.DataPropertyName = "stable";
		dataGridViewCellStyle17.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
		this.dataGridViewTextBoxColumn11.DefaultCellStyle = dataGridViewCellStyle17;
		this.dataGridViewTextBoxColumn11.FillWeight = 90.39594f;
		this.dataGridViewTextBoxColumn11.HeaderText = "峰宽(AMU)";
		this.dataGridViewTextBoxColumn11.MinimumWidth = 6;
		this.dataGridViewTextBoxColumn11.Name = "dataGridViewTextBoxColumn11";
		this.dataGridViewTextBoxColumn11.ReadOnly = true;
		this.dataGridViewTextBoxColumn11.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
		this.dataGridViewTextBoxColumn11.Width = 50;
		this.dataGridViewTextBoxColumn12.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
		this.dataGridViewTextBoxColumn12.DataPropertyName = "Color";
		dataGridViewCellStyle18.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
		this.dataGridViewTextBoxColumn12.DefaultCellStyle = dataGridViewCellStyle18;
		this.dataGridViewTextBoxColumn12.FillWeight = 115.736f;
		this.dataGridViewTextBoxColumn12.HeaderText = "误差(AMU)";
		this.dataGridViewTextBoxColumn12.MinimumWidth = 6;
		this.dataGridViewTextBoxColumn12.Name = "dataGridViewTextBoxColumn12";
		this.dataGridViewTextBoxColumn12.ReadOnly = true;
		this.dataGridViewTextBoxColumn12.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
		this.dataGridViewTextBoxColumn12.Width = 49;
		this.dataGridViewTextBoxColumn13.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
		this.dataGridViewTextBoxColumn13.DataPropertyName = "Ratio";
		dataGridViewCellStyle19.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
		this.dataGridViewTextBoxColumn13.DefaultCellStyle = dataGridViewCellStyle19;
		this.dataGridViewTextBoxColumn13.FillWeight = 96.85279f;
		this.dataGridViewTextBoxColumn13.HeaderText = "符号";
		this.dataGridViewTextBoxColumn13.MinimumWidth = 6;
		this.dataGridViewTextBoxColumn13.Name = "dataGridViewTextBoxColumn13";
		this.dataGridViewTextBoxColumn13.ReadOnly = true;
		this.dataGridViewTextBoxColumn13.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
		this.dataGridViewTextBoxColumn13.Width = 50;
		this.dataGridViewTextBoxColumn14.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
		this.dataGridViewTextBoxColumn14.DataPropertyName = "Stability";
		dataGridViewCellStyle20.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
		this.dataGridViewTextBoxColumn14.DefaultCellStyle = dataGridViewCellStyle20;
		this.dataGridViewTextBoxColumn14.FillWeight = 96.85279f;
		this.dataGridViewTextBoxColumn14.HeaderText = "质量数";
		this.dataGridViewTextBoxColumn14.MinimumWidth = 6;
		this.dataGridViewTextBoxColumn14.Name = "dataGridViewTextBoxColumn14";
		this.dataGridViewTextBoxColumn14.ReadOnly = true;
		this.dataGridViewTextBoxColumn14.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
		this.dataGridViewTextBoxColumn14.Width = 49;
		this.dataGridViewTextBoxColumn15.HeaderText = "稳定性";
		this.dataGridViewTextBoxColumn15.MinimumWidth = 6;
		this.dataGridViewTextBoxColumn15.Name = "dataGridViewTextBoxColumn15";
		this.dataGridViewTextBoxColumn15.Width = 50;
		dataGridViewCellStyle21.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
		this.dataGridViewTextBoxColumn16.DefaultCellStyle = dataGridViewCellStyle21;
		this.dataGridViewTextBoxColumn16.HeaderText = "符号";
		this.dataGridViewTextBoxColumn16.MinimumWidth = 6;
		this.dataGridViewTextBoxColumn16.Name = "dataGridViewTextBoxColumn16";
		this.dataGridViewTextBoxColumn16.ReadOnly = true;
		this.dataGridViewTextBoxColumn16.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
		this.dataGridViewTextBoxColumn16.Width = 50;
		this.dataGridViewTextBoxColumn17.DataPropertyName = "begin";
		dataGridViewCellStyle22.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
		this.dataGridViewTextBoxColumn17.DefaultCellStyle = dataGridViewCellStyle22;
		this.dataGridViewTextBoxColumn17.HeaderText = "质量数";
		this.dataGridViewTextBoxColumn17.MinimumWidth = 6;
		this.dataGridViewTextBoxColumn17.Name = "dataGridViewTextBoxColumn17";
		this.dataGridViewTextBoxColumn17.ReadOnly = true;
		this.dataGridViewTextBoxColumn17.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
		this.dataGridViewTextBoxColumn17.Width = 125;
		this.dataGridViewTextBoxColumn18.DataPropertyName = "end";
		dataGridViewCellStyle24.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
		this.dataGridViewTextBoxColumn18.DefaultCellStyle = dataGridViewCellStyle24;
		this.dataGridViewTextBoxColumn18.HeaderText = "DAC数值";
		this.dataGridViewTextBoxColumn18.MinimumWidth = 6;
		this.dataGridViewTextBoxColumn18.Name = "dataGridViewTextBoxColumn18";
		this.dataGridViewTextBoxColumn18.ReadOnly = true;
		this.dataGridViewTextBoxColumn18.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
		this.dataGridViewTextBoxColumn18.Width = 125;
		this.dataGridViewTextBoxColumn19.DataPropertyName = "channels";
		dataGridViewCellStyle25.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
		this.dataGridViewTextBoxColumn19.DefaultCellStyle = dataGridViewCellStyle25;
		this.dataGridViewTextBoxColumn19.HeaderText = "峰宽(AMU)";
		this.dataGridViewTextBoxColumn19.MinimumWidth = 6;
		this.dataGridViewTextBoxColumn19.Name = "dataGridViewTextBoxColumn19";
		this.dataGridViewTextBoxColumn19.ReadOnly = true;
		this.dataGridViewTextBoxColumn19.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
		this.dataGridViewTextBoxColumn19.Width = 120;
		this.dataGridViewTextBoxColumn20.DataPropertyName = "coef1";
		dataGridViewCellStyle26.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
		this.dataGridViewTextBoxColumn20.DefaultCellStyle = dataGridViewCellStyle26;
		this.dataGridViewTextBoxColumn20.HeaderText = "误差(AMU)";
		this.dataGridViewTextBoxColumn20.MinimumWidth = 6;
		this.dataGridViewTextBoxColumn20.Name = "dataGridViewTextBoxColumn20";
		this.dataGridViewTextBoxColumn20.ReadOnly = true;
		this.dataGridViewTextBoxColumn20.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
		this.dataGridViewTextBoxColumn20.Width = 125;
		this.dataGridViewTextBoxColumn21.DataPropertyName = "coef2";
		dataGridViewCellStyle27.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
		this.dataGridViewTextBoxColumn21.DefaultCellStyle = dataGridViewCellStyle27;
		this.dataGridViewTextBoxColumn21.HeaderText = "符号";
		this.dataGridViewTextBoxColumn21.MinimumWidth = 6;
		this.dataGridViewTextBoxColumn21.Name = "dataGridViewTextBoxColumn21";
		this.dataGridViewTextBoxColumn21.ReadOnly = true;
		this.dataGridViewTextBoxColumn21.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
		this.dataGridViewTextBoxColumn21.Width = 125;
		this.dataGridViewTextBoxColumn22.DataPropertyName = "note";
		dataGridViewCellStyle28.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
		this.dataGridViewTextBoxColumn22.DefaultCellStyle = dataGridViewCellStyle28;
		this.dataGridViewTextBoxColumn22.HeaderText = "质量数";
		this.dataGridViewTextBoxColumn22.MinimumWidth = 6;
		this.dataGridViewTextBoxColumn22.Name = "dataGridViewTextBoxColumn22";
		this.dataGridViewTextBoxColumn22.ReadOnly = true;
		this.dataGridViewTextBoxColumn22.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
		this.dataGridViewTextBoxColumn22.Width = 125;
		this.dataGridViewTextBoxColumn23.DataPropertyName = "symbol";
		dataGridViewCellStyle29.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
		this.dataGridViewTextBoxColumn23.DefaultCellStyle = dataGridViewCellStyle29;
		this.dataGridViewTextBoxColumn23.HeaderText = "质量数";
		this.dataGridViewTextBoxColumn23.MinimumWidth = 6;
		this.dataGridViewTextBoxColumn23.Name = "dataGridViewTextBoxColumn23";
		this.dataGridViewTextBoxColumn23.ReadOnly = true;
		this.dataGridViewTextBoxColumn23.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
		this.dataGridViewTextBoxColumn23.Width = 125;
		this.dataGridViewTextBoxColumn24.DataPropertyName = "mass";
		dataGridViewCellStyle30.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
		this.dataGridViewTextBoxColumn24.DefaultCellStyle = dataGridViewCellStyle30;
		this.dataGridViewTextBoxColumn24.HeaderText = "质量数";
		this.dataGridViewTextBoxColumn24.MinimumWidth = 6;
		this.dataGridViewTextBoxColumn24.Name = "dataGridViewTextBoxColumn24";
		this.dataGridViewTextBoxColumn24.ReadOnly = true;
		this.dataGridViewTextBoxColumn24.Width = 125;
		this.dataGridViewTextBoxColumn25.DataPropertyName = "dac";
		dataGridViewCellStyle31.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
		this.dataGridViewTextBoxColumn25.DefaultCellStyle = dataGridViewCellStyle31;
		this.dataGridViewTextBoxColumn25.HeaderText = "计数";
		this.dataGridViewTextBoxColumn25.MinimumWidth = 6;
		this.dataGridViewTextBoxColumn25.Name = "dataGridViewTextBoxColumn25";
		this.dataGridViewTextBoxColumn25.ReadOnly = true;
		this.dataGridViewTextBoxColumn25.Width = 125;
		this.dataGridViewTextBoxColumn26.DataPropertyName = "width";
		dataGridViewCellStyle32.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
		this.dataGridViewTextBoxColumn26.DefaultCellStyle = dataGridViewCellStyle32;
		this.dataGridViewTextBoxColumn26.HeaderText = "峰宽(AMU)";
		this.dataGridViewTextBoxColumn26.MinimumWidth = 6;
		this.dataGridViewTextBoxColumn26.Name = "dataGridViewTextBoxColumn26";
		this.dataGridViewTextBoxColumn26.ReadOnly = true;
		this.dataGridViewTextBoxColumn26.Width = 125;
		this.dataGridViewTextBoxColumn27.DataPropertyName = "error";
		dataGridViewCellStyle33.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
		this.dataGridViewTextBoxColumn27.DefaultCellStyle = dataGridViewCellStyle33;
		this.dataGridViewTextBoxColumn27.HeaderText = "误差";
		this.dataGridViewTextBoxColumn27.MinimumWidth = 6;
		this.dataGridViewTextBoxColumn27.Name = "dataGridViewTextBoxColumn27";
		this.dataGridViewTextBoxColumn27.ReadOnly = true;
		this.dataGridViewTextBoxColumn27.Width = 125;
		this.graphControlTuneGraph.Dock = System.Windows.Forms.DockStyle.Fill;
		this.graphControlTuneGraph.Location = new System.Drawing.Point(0, 0);
		this.graphControlTuneGraph.Margin = new System.Windows.Forms.Padding(5, 4, 5, 4);
		this.graphControlTuneGraph.Name = "graphControlTuneGraph";
		this.graphControlTuneGraph.ScrollGrace = 0.0;
		this.graphControlTuneGraph.ScrollMaxX = 0.0;
		this.graphControlTuneGraph.ScrollMaxY = 0.0;
		this.graphControlTuneGraph.ScrollMaxY2 = 0.0;
		this.graphControlTuneGraph.ScrollMinX = 0.0;
		this.graphControlTuneGraph.ScrollMinY = 0.0;
		this.graphControlTuneGraph.ScrollMinY2 = 0.0;
		this.graphControlTuneGraph.Size = new System.Drawing.Size(1145, 441);
		this.graphControlTuneGraph.TabIndex = 1;
		base.AutoScaleDimensions = new System.Drawing.SizeF(8f, 15f);
		base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
		base.ClientSize = new System.Drawing.Size(1153, 908);
		base.Controls.Add(this.tableLayoutPanel1);
		base.Controls.Add(this.toolStrip1);
		base.Icon = (System.Drawing.Icon)resources.GetObject("$this.Icon");
		base.Margin = new System.Windows.Forms.Padding(4);
		base.Name = "FormInstrumentTuneDebug";
		base.ShowIcon = false;
		this.Text = "调谐(测试专用)";
		base.FormClosing += new System.Windows.Forms.FormClosingEventHandler(FormInstrumentSetup_FormClosing);
		base.Load += new System.EventHandler(FormInstrument_Load);
		this.tableLayoutPanel1.ResumeLayout(false);
		this.panel1.ResumeLayout(false);
		this.tableLayoutPanel4.ResumeLayout(false);
		((System.ComponentModel.ISupportInitialize)this.dgvTuneRatio).EndInit();
		((System.ComponentModel.ISupportInitialize)this.dgvTuneIsotopes).EndInit();
		this.toolStrip1.ResumeLayout(false);
		this.toolStrip1.PerformLayout();
		base.ResumeLayout(false);
		base.PerformLayout();
	}
}
